import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:包含不超过两种字符的子串
 * User: wangxin
 * Date: 2024-10-17
 * Time: 22:46
 */
public class test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        HashMap<Character, Integer> map = new HashMap<>();

        String s = in.next();
        int n = s.length();

        int left = 0, right = 0;
        int max_len = 2;

        while (right < n) {
            if (map.size() < 3) {
                map.put(s.charAt(right), right ++ );
            }
            if (map.size() == 3) {
                int led_idx = Collections.min(map.values());
                map.remove(s.charAt(led_idx));
                left = led_idx + 1;
            }
            max_len = Math.max(max_len, right - left);
        }
        System.out.println(max_len);
    }
}
